/*
 * VHTypeConverter.java
 * Created on 26 mai 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package com.hockeo.vhweb.server.convert;

/**
 * Converts the value being an instance of type T into a value being an instance of type
 * E.
 *
 * @version $Id$
 * @author jjanke
 */
interface VHTypeConverter<T, E>
{
  /**
   * Converts the given input value of type T into an instance of type E.
   *
   * @param obj the object to be converted
   * @return the converted object
   */
  public E convert( T obj );

  /**
   * Convenience method that casts the given object to the type T prior to converting it.
   *
   * @param obj the object to be casted to T and then converted to E
   * @return the converted object
   */
  public E castAndConvert( Object obj );

  /**
   * Returns a {@link Class} object representing the type to be converted.
   */
  public Class<T> getSourceType();

  /**
   * Returns a {@link Class} object representing the type into which instances of the
   * source type should be converted.
   */
  public Class<E> getDestType();
}
